/**
 * 抽屉 hooks
 * @Author: linzy
 * @Date: 2022-08-29
 * @function useDrawer
 * @property {} props - 默认值： <br />
 * closable: false, <br />
 * placement: 'left', <br />
    onClose() {
      visibleSet(false);
    }, <br />
    width: 'max(500px,30vw)', <br />
 * @returns [Drawer, drawerProps, setVisible]
 * @example
 const [Drawer, DrawerProps, setVisible] = useDrawer()
<Drawer {...DrawerProps}></Drawer>
*/
import { Drawer } from "antd";
import { useState } from "react";
import { setDefaultAttrs } from "@/hooks/tools";

export default (props = {}) => {
  const [visible, visibleSet] = useState(false);
  setDefaultAttrs(props, {
    visible,
    placement: "left",
    onClose() {
      visibleSet(false);
    },
    width: "max(500px,30vw)"
  });
  return [Drawer, props, visibleSet];
};
